# 权限模型定义
from backend.infrastructure.database import db

class Permission(db.Model):
    __tablename__ = 'permissions'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    code = db.Column(db.String(100), unique=True, nullable=False, comment="权限代码")
    name = db.Column(db.String(50), nullable=False, comment="权限名称")
    description = db.Column(db.String(255), nullable=True, comment="权限描述")
    status = db.Column(db.String(20), nullable=False, default="enabled", comment="状态")

    def to_dict(self):
        return {
            'id': self.id,
            'code': self.code,
            'name': self.name,
            'description': self.description,
            'status': self.status
        }
